﻿@model IEnumerable<yule.Model.Sys.User>
@{
    yule.Util.RunTime rt = new yule.Util.RunTime();
    
    ViewBag.Title = "用户列表";
    Url.Action("Detail");
}
<table id="table_data">
    <tr>
        <th>Id</th>
        <th>Name</th>
        <th>State</th>
        <th>RegionId</th>
        <th>RegionName</th>
        <th>RegionFullName</th>
        <th>操作</th>
    </tr>
@if (Model != null)
{
    foreach (var item in Model)
    {
        <tr>
            <td>@item.Id</td>
            <td>@item.Name</td>
            <td>@item.State</td>
            <td>@item.RegionId</td>
            <td>@(item.Region == null ? string.Empty : item.Region.Name)</td>
            <td>@(item.Region == null ? string.Empty : item.Region.PathName)</td>
            <td>
                <a href="@Url.Action("Details")?id=@item.Id">详细</a>
                <a onclick="Details('@item.Id','@item.Name');" href="#">Ajax详细</a>
                <a onclick="return confirmDelete('@item.Name','@item.Id');" href="#" >删除</a>
            </td>
        </tr>
    }
}
</table>

<div><a href="#" onclick="Insert();">新增</a></div>

<div style="display:none;" id="insertPanel">
    @{
        ViewDataDictionary vd = new ViewDataDictionary(new yule.Model.Sys.User());
        //回调需要设置这个；哎很麻烦 需要考虑下不过效果可能不错
        //vd["CallBackFun"] = "InsertCallBack";
    }
    @Html.Partial("Insert", vd)
</div>

<script type="text/javascript">

    //主要为了测试同步Ajax
    function Details(id,name) {
        
        $.blockUI();
        
        $.ajax({
            url:"@Url.Action("Details")?id="+id,
            success:function(html){
                alert(html,name);
            },
            complete:function(){
                $.unblockUI();
            }
        });
    }

    function Insert(){
        alert($("#insertPanel").html(),"新增",{ok:false});
    };

    //插入回调
    function InsertCallBack(){
        alert("插入完成");
    }

    function confirmDelete(msg,id) {
        var message = "确定要删除信息:<span style='color:red;'><</span>" + msg + "<span style='color:red;'>></span>吗？";
        $.confirm(message,("删除:"+msg), function () {
            window.location = "@Url.Action("Delete")?id="+id;
        });
    };

    var CurrentMenu = "用户";
</script>

<div class="PageLoadInfo">@(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 页面加载消耗 " + rt.GetTotal() + " 毫秒")</div>